function newNormalImageMaterial(imgUrl, scene) {
  var mat = new BABYLON.StandardMaterial("mat1", scene);
  mat.alpha = 1.0;
  mat.diffuseColor = new BABYLON.Color3(0.5, 0.5, 1.0); //没见到效果

  var texture = new BABYLON.Texture(imgUrl, scene);
  mat.diffuseTexture = texture;

  return mat;
}

function newImagePlane(imgUrl, scene) {

  var mat = newNormalImageMaterial(imgUrl, scene);
  var imgSize = getImageSize(imgUrl);

  var options = {
    width: imgSize.width*0.0025,
    height: imgSize.height*0.0025,
    depth: 5,
  };

  var plane = BABYLON.MeshBuilder.CreatePlane('box', options, scene);
  //plane.position = new BABYLON.Vector3(1, 1, 0); //x,y,z:  x越大，靠近照相机，y越大，靠近上边，z越大，靠右边，是故照相机0,0,0时位于x正轴上，面向负轴
  plane.material = mat;

  return plane;
}

//获取图片尺寸
function getImageSize(filePath) {
    var pic = new Image();
    pic.src = filePath;//图片的url地址

    var size = new Object();
    size.width = 640;
    size.height = 869;

    return size;
}

function startCamera(meshArray) {
  for (var i = 0; i < meshArray.length; i++) {
    meshArray[i].actionManager = new BABYLON.ActionManager(game.scene);
    var condition1 = new BABYLON.PredicateCondition(meshArray[i].actionManager, function() {
      return true;
    });
    meshArray[i].actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLeftPickTrigger, function(evt) {
      cameraTo(game.camera, evt.source);
    }, condition1));
  }
}

function startAnimation(type) {
  if(type==0){
    var formation_xyz = createFormation_xyz(new BABYLON.Vector3(-16, -8, 0), 5, 5, 4, 6, 6, 4);
    game.camera.radius = 2.5;
    game.camera.heightOffset = 0;

    var randArray = createDifferentRandomInt(formation_xyz.length, formation_xyz.length);
    for (var i = 0; i < 144; i++) {
      var rand = randArray[i];
      var tmp = formation_xyz[rand];
      formation_xyz[rand] = formation_xyz[i];
      formation_xyz[i] = tmp;
    }
    for (var i = 0; i < 144; i++) {
      showAnimation(game.picArray[i], game.picArray[i].position, formation_xyz[i]);
      game.scene.beginAnimation(game.picArray[i], 0, 100, true);
    }
  }else if(type==1){
    var formation_circle = createFormation_circle(new BABYLON.Vector3(-16, -8, 0), 40 ,144);
    game.camera.radius = 30;
    game.camera.heightOffset = 5;

    var randArray = createDifferentRandomInt(formation_circle.length, formation_circle.length);
    for (var i = 0; i < formation_circle.length; i++) {
      var rand = randArray[i];
      var tmp = formation_circle[rand];
      formation_circle[rand] = formation_circle[i];
      formation_circle[i] = tmp;
    }

    for (var i = 0; i < 144; i++) {
      showAnimation(game.picArray[i], game.picArray[i].position, formation_circle[i]);
      game.scene.beginAnimation(game.picArray[i], 0, 100, true);
    }
  }

}
